// PassengerPartitioner.java
package com.taxi.analysis.passengerTrip;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * 乘客分区器
 * 确保同一乘客的数据被发送到同一个Reducer
 */
public class PassengerPartitioner extends Partitioner<PassengerTripKey, Text> {

    @Override
    public int getPartition(PassengerTripKey key, Text value, int numPartitions) {
        // 基于乘客ID进行分区
        return (key.getPassengerId().hashCode() & Integer.MAX_VALUE) % numPartitions;
    }
}
